<?php
include('../../include/functions.inc.php');
$list = $db->query_select("cllg_career", "FK_ENTITY=" . $user->entity);
$listCycles = $db->query_select("cllg_college_cycle", "FK_ENTITY=" . $user->entity);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Notas Por Curso</title>
        <link href="../../bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />
        <link href="../../css/ContentStyle.css" rel="stylesheet" type="text/css" />
        
        
        <link href="../../js/dialog/dialog.2.0.css" rel="stylesheet" type="text/css" />
        <script src="../../js/prototype.js" type="text/javascript"></script>
        <script src="../../js/jquery.js" type="text/javascript"></script>
        <script>jQuery.noConflict();</script>
        <script src="../../bootstrap/js/bootstrap.js"></script>
        <script src="uploader.js" type="text/javascript"></script>
        <script src="../../js/jsvalidate.js" type="text/javascript"></script>
        <script src="../../js/TableOrderer.js" type="text/javascript"></script>
        <script src="../../js/dialog/dialog.2.0.js" type="text/javascript"></script>
        <script src="../../js/include.js" type="text/javascript"></script>
        <script type="text/javascript">
            var cargos=null;

            var rsv;
            config=function(){ 
                rsv=new RSV({
                    formID: $(document.ASIGNACION),
                    errorFieldClass: "errorField",
                    rules: ["required,NAME,Debe buscar un Catedratico!"],
                    displayType : "display-html",
                    errorHTMLItemBullet : "&#8212; ",
                    onCompleteHandler:function(){
                        waitMsg("Asignado...")
                        $('operation').value='prev';
                        $(document.ASIGNACION).request({onComplete:function(r){
                                if(r.responseJSON.ST==1){
                                    $('operation').value='s';
                                    $(document.ASIGNACION).submit();
                                }else{
                                    Dialogs.alert(r.responseJSON.ERROR);
                                }
                            }});
							
                    }});
            }

            addOnLoad(config);

            showTeach=function(){
                var f=new Hash({tittle:'Listado de Catedraticos',url:'../teachers/list.php',callback:selTeach,width:500,height:500});
                setList(null,f.toObject());
            }
            selTeach=function(s){
                $("ID").value=s.ID;
                $("NAME").value=s.NOMBRES+' '+s.APELLIDOS;
                closeWait();
            }
            showCursos=function(){
                waitMsg("Cargando...");
                new Ajax.Updater("cursos","combo.php?"+$(document.forms[0]).serialize(),
                {parameters:"ID="+$F("ID"),
                    onComplete:function(r){
                        $("CURSO").observe("change",showListado);
                        closeWait();
                    }});
            }
            showListado=function(e){
                var el=Event.element(e);
                if(el.selectedIndex>0){
                    waitMsg("Cargando...");
                    
                    var pars="ID="+el.value+"&CYCLE="+$F("CYCLE");
                    new Ajax.Updater("estudiantes","studenList.php",{parameters:pars,
                        onComplete:function(r){
                            closeWait();
                        }});
                }
            }
            var backup;
            function printAll(){
                var pars="ID="+$F("CURSO")+"&print=true&CYCLE="+$F("CYCLE");
                backup=$("estudiantes").innerHTML;
   
                new Ajax.Updater("estudiantes","studenList.php",{parameters:pars,
                    onComplete:function(r){
                        closeWait();
                        $("print").hide();
                        window.print();
                        $("print").show();
                    }});
            }
            window.onafterprint=function(){
                $("estudiantes").update(backup);
            }

        </script>
    </head>

    <body>
        <div id="rsvErrors"></div>

        <table class=""  width="100%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <th scope="col"><ul class="nav nav-tabs"><li class="active"><a>Consulta de Alumnos por Catedraticos</a></li></ul></th>
            </tr>
            <tr>
                <td>
                    <form action="data.php" method="GET" enctype="multipart/form-data" name="ASIGNACION" id="ASIGNACION">
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td width="20%">ID CATEDRATICO</td>
                                <td width="80%">            <input name="ID" type="text" readonly="readonly" id="ID" />
                                    <input name="buscar" onclick="showTeach()" type="button" class="btn btn-small" id="buscar"  value=".." />            </td>
                            </tr>


                            <tr>
                                <td>NOMBRE </td>
                                <td><input name="NAME" type="text" id="NAME" readonly="readonly" size="50" /></td>
                            </tr>
                            <tr>
                                <td >CICLO ESTUDIO</td>
                                <td ><select name="CYCLE" id="CYCLE" onchange="showCursos();">
                                        <option value="" selected="selected">Seleccione</option>
                                        <?php foreach ($listCycles as $it) { ?>
                                            <option value="<?php echo $it["CODE"]; ?>"><?php echo $it["CODE"]; ?> </option>
                                        <?php } ?>
                                    </select></td>
                            </tr>        
                            <tr>
                                <td>CURSO IMPARTIDO</td>
                                <td id="cursos"><select name="CURSO" id="CURSO">
                                    </select>          </td>
                            </tr>

                            <tr>
                                <td >&nbsp;</td>
                                <td ><input name="print" type="button" class="btn btn-info" onclick="printAll();" id="print" value="Imprimir" /><br/></td>
                            </tr>
                            <tr>
                                <td colspan="2" id="estudiantes">&nbsp;</td>
                            </tr>
                        </table>
                    </form></td>
            </tr>
            <tr>
                <td id="uploader"></td>
            </tr>
        </table>


    </body>
</html>
